/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/shape_inference.h"
#include "tensorflow/core/framework/resource_op_kernel.h"
#include "tf_adapter/common/adapter_logger.h"
#include "tf_adapter/util/cache_interface.h"

namespace tensorflow {
class InitPartitionMapOp : public OpKernel {
public:
  explicit InitPartitionMapOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~InitPartitionMapOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "InitPartitionMapOp Compute"; }
};

class InitEmbeddingHashmapOp : public OpKernel {
public:
  explicit InitEmbeddingHashmapOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~InitEmbeddingHashmapOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "InitEmbeddingHashmapOp Compute"; }
};

class EmbeddingTableFindOp : public OpKernel {
public:
  explicit EmbeddingTableFindOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingTableFindOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingTableFindOp Compute"; }
};

class EmbeddingTableImportOp : public OpKernel {
public:
  explicit EmbeddingTableImportOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingTableImportOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingTableImportOp Compute"; }
};

class UninitPartitionMapOp : public OpKernel {
public:
  explicit UninitPartitionMapOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~UninitPartitionMapOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "UninitPartitionMapOp Compute"; }
};

class UninitEmbeddingHashmapOp : public OpKernel {
public:
  explicit UninitEmbeddingHashmapOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~UninitEmbeddingHashmapOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "UninitEmbeddingHashmapOp Compute"; }
};

class TableToResourceOp : public OpKernel {
public:
  explicit TableToResourceOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~TableToResourceOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "TableToResourceOp Compute"; }
};

class EmbeddingTableFindAndInitOp : public OpKernel {
public:
  explicit EmbeddingTableFindAndInitOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingTableFindAndInitOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingTableFindAndInitOp Compute"; }
};

class FakeRemoteLookupUniquedOp : public OpKernel {
 public:
  explicit FakeRemoteLookupUniquedOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~FakeRemoteLookupUniquedOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "FakeRemoteLookupUniquedOp Compute"; }
};

class EmbeddingApplyAdamOp : public OpKernel {
public:
  explicit EmbeddingApplyAdamOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingApplyAdamOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingApplyAdamOp Compute"; }
};

class EmbeddingApplyAdamWOp : public OpKernel {
public:
  explicit EmbeddingApplyAdamWOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingApplyAdamWOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingApplyAdamWOp Compute"; }
};

class EmbeddingApplyAdaGradOp : public OpKernel {
public:
  explicit EmbeddingApplyAdaGradOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingApplyAdaGradOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingApplyAdaGradOp Compute"; }
};

class EmbeddingApplySgdOp : public OpKernel {
public:
  explicit EmbeddingApplySgdOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingApplySgdOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingApplySgdOp Compute"; }
};

class EmbeddingApplyRmspropOp : public OpKernel {
public:
  explicit EmbeddingApplyRmspropOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingApplyRmspropOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingApplyRmspropOp Compute"; }
};

class EmbeddingApplyFtrlOp : public OpKernel {
public:
  explicit EmbeddingApplyFtrlOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingApplyFtrlOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingApplyFtrlOp Compute"; }
};

class ExponentialDecayLROp : public OpKernel {
public:
  explicit ExponentialDecayLROp(OpKernelConstruction *context) : OpKernel(context) {}
  ~ExponentialDecayLROp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "ExponentialDecayLROp Compute"; }
};

class EmbeddingComputeVarExportOp : public OpKernel {
public:
  explicit EmbeddingComputeVarExportOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingComputeVarExportOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingComputeVarExportOp Compute"; }
};

class EmbeddingComputeVarImportOp : public OpKernel {
public:
  explicit EmbeddingComputeVarImportOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingComputeVarImportOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingComputeVarImportOp Compute"; }
};

class EmbeddingTableExportOp : public OpKernel {
public:
  explicit EmbeddingTableExportOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingTableExportOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingTableExportOp Compute"; }
};

class EmbeddingFeatureMappingOp : public OpKernel {
public:
  explicit EmbeddingFeatureMappingOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingFeatureMappingOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingFeatureMappingOp Compute"; }
};

class EmbeddingFeatureMappingV2Op : public OpKernel {
public:
  explicit EmbeddingFeatureMappingV2Op(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingFeatureMappingV2Op() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingFeatureMappingV2Op Compute"; }
};

class EmbeddingFeatureMappingTableSizeOp : public OpKernel {
public:
  explicit EmbeddingFeatureMappingTableSizeOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingFeatureMappingTableSizeOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingFeatureMappingTableSizeOp Compute"; }
};

class EmbeddingFeatureMappingFindOp : public OpKernel {
public:
  explicit EmbeddingFeatureMappingFindOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingFeatureMappingFindOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingFeatureMappingFindOp Compute"; }
};

class EmbeddingFeatureMappingExportOp : public OpKernel {
public:
  explicit EmbeddingFeatureMappingExportOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingFeatureMappingExportOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingFeatureMappingExportOp Compute"; }
};

class EmbeddingFeatureMappingFileSizeOp : public OpKernel {
public:
  explicit EmbeddingFeatureMappingFileSizeOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingFeatureMappingFileSizeOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingFeatureMappingFileSizeOp Compute"; }
};

class EmbeddingFeatureMappingImportOp : public OpKernel {
public:
  explicit EmbeddingFeatureMappingImportOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingFeatureMappingImportOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingFeatureMappingImportOp Compute"; }
};

class EmbeddingFeatureMappingInsertOp : public OpKernel {
public:
  explicit EmbeddingFeatureMappingInsertOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingFeatureMappingInsertOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingFeatureMappingInsertOp Compute"; }
};

class EmbeddingTableEvictOp : public OpKernel {
public:
  explicit EmbeddingTableEvictOp(OpKernelConstruction *context) : OpKernel(context) {}
  ~EmbeddingTableEvictOp() override {}
  void Compute(OpKernelContext *context) override { ADP_LOG(INFO) << "EmbeddingTableEvictOp Compute"; }
};

REGISTER_KERNEL_BUILDER(Name("InitPartitionMap").Device(DEVICE_CPU), InitPartitionMapOp);
REGISTER_KERNEL_BUILDER(Name("InitEmbeddingHashmap").Device(DEVICE_CPU), InitEmbeddingHashmapOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingTableFind").Device(DEVICE_CPU), EmbeddingTableFindOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingTableImport").Device(DEVICE_CPU), EmbeddingTableImportOp);
REGISTER_KERNEL_BUILDER(Name("UninitPartitionMap").Device(DEVICE_CPU), UninitPartitionMapOp);
REGISTER_KERNEL_BUILDER(Name("UninitEmbeddingHashmap").Device(DEVICE_CPU), UninitEmbeddingHashmapOp);
REGISTER_KERNEL_BUILDER(Name("TableToResource").Device(DEVICE_CPU), TableToResourceOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingTableFindAndInit").Device(DEVICE_CPU), EmbeddingTableFindAndInitOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingApplyAdam").Device(DEVICE_CPU), EmbeddingApplyAdamOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingApplyAdamW").Device(DEVICE_CPU), EmbeddingApplyAdamWOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingApplyAdaGrad").Device(DEVICE_CPU), EmbeddingApplyAdaGradOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingApplySgd").Device(DEVICE_CPU), EmbeddingApplySgdOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingApplyRmsprop").Device(DEVICE_CPU), EmbeddingApplyRmspropOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingApplyFtrl").Device(DEVICE_CPU), EmbeddingApplyFtrlOp);
REGISTER_KERNEL_BUILDER(Name("ExponentialDecayLR").Device(DEVICE_CPU), ExponentialDecayLROp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingTableExport").Device(DEVICE_CPU), EmbeddingTableExportOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingFeatureMapping").Device(DEVICE_CPU), EmbeddingFeatureMappingOp);
REGISTER_KERNEL_BUILDER(Name("FakeRemoteLookupUniqued").Device(DEVICE_CPU), FakeRemoteLookupUniquedOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingComputeVarExport").Device(DEVICE_CPU), EmbeddingComputeVarExportOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingComputeVarImport").Device(DEVICE_CPU), EmbeddingComputeVarImportOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingFeatureMappingV2").Device(DEVICE_CPU), EmbeddingFeatureMappingV2Op);
REGISTER_KERNEL_BUILDER(Name("EmbeddingFeatureMappingTableSize").Device(DEVICE_CPU), EmbeddingFeatureMappingTableSizeOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingFeatureMappingFind").Device(DEVICE_CPU), EmbeddingFeatureMappingFindOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingFeatureMappingExport").Device(DEVICE_CPU), EmbeddingFeatureMappingExportOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingFeatureMappingFileSize").Device(DEVICE_CPU), EmbeddingFeatureMappingFileSizeOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingFeatureMappingImport").Device(DEVICE_CPU), EmbeddingFeatureMappingImportOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingFeatureMappingInsert").Device(DEVICE_CPU), EmbeddingFeatureMappingInsertOp);
REGISTER_KERNEL_BUILDER(Name("EmbeddingTableEvict").Device(DEVICE_CPU), EmbeddingTableEvictOp);
}  // namespace tensorflow